package com.flw.eslab.action.admin;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.stereotype.Controller;

import com.flw.eslab.dto.PageInfo_Dto;
import com.flw.eslab.dto.Project_Dto;
import com.flw.eslab.service.ProjectManager;
import com.flw.eslab.service.UserManager;

@Controller
@Results({
	@Result(name = "tolist", location = "info?jump_url=list", type = "redirect"),
	@Result(name = "toAdd", location = "info?jump_url=add", type = "redirect")})
public class ProjectAction extends CommonAction {

	private Project_Dto project_Dto = new Project_Dto();
	private ProjectManager projectManager;
	public PageInfo_Dto getPageInfo_Dto() {
		return pageInfo_Dto;
	}

	public void setPageInfo_Dto(PageInfo_Dto pageInfo_Dto) {
		this.pageInfo_Dto = pageInfo_Dto;
	}

	public ProjectManager getProjectManager() {
		return projectManager;
	}

	private PageInfo_Dto pageInfo_Dto;
	
	public String add() {
		if(projectManager.add(project_Dto.toProject())){
			session.put("msg", "项目添加成功");
			return "tolist";
		}
		else{
			session.put("msg", "项目添加不成功,项目名不能为空");
			return "toAdd";	
		}
	}

	public String load() {

		setPageInfo_Dto(projectManager.load(pageInfo_Dto));
		return "success";
	}

	public String project() {
		return "project";
	}

	/*--------------------------------*/
	public Project_Dto getProject_Dto() {
		return project_Dto;
	}

	public void setProject_Dto(Project_Dto project_Dto) {
		this.project_Dto = project_Dto;
	}

	/*--------------------------------*/
	@Resource
	public void setProjectManager(ProjectManager projectManager) {
		this.projectManager = projectManager;
	}
}
